/*
 * @Author: your name
 * @Date: 2021-10-08 08:27:25
 * @LastEditTime: 2021-10-08 09:08:36
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \luogu\1.5贪心\P1478\main.cpp
 */
#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;

typedef struct Apple{
  //苹果高度
  int high;
  //摘苹果花费体力
  int strength;
}apple;

//按照力气代价排序
void sortByStrength(apple** app,int l,int r);
//打印苹果数组
void printApple(apple** app,int l,int n);
int main(){
  int n,s,a,b;
  apple** app;
  cin >> n >> s >> a >> b;
  app = (apple** )malloc(sizeof(apple*)*(n+2));
  if(!app){
    printf("no memory\n");
    exit(-1);
  }
  for(int i=1; i<=n; i++){
    app[i] = (apple* )malloc(sizeof(apple));
    cin >> app[i]->high >> app[i]->strength;
  }
  // cout << "------------------" << endl;
  sortByStrength(app,1,n);
  // cout << "------------------" << endl;
  // printApple(app,1,n);

  //在高度小于a+b的范围内,摘桃
  int max_high = a+b;
  int apple_num = 0;
  for(int i=1; i<=n; i++){
    if(app[i]->high <= a+b && s >= app[i]->strength){
      apple_num++;
      s -= app[i]->strength;
    }
  }
  // cout << "get apple num:" << apple_num << endl;
  cout << apple_num;

  //释放空间
  for(int i=1; i<=n; i++){
    free(app[i]);
  }
  if(app){
    free(app);
  }
  return 0;
}
void sortByStrength(apple** app,int l,int r)
{
  if(l < r){
    int low = l;
    int high = r;
    // apple* pivot = app[l];
    //随机化处理
    srand(time(NULL));
    int randNum = rand()%(r-l+1)+l;
    apple* pivot = app[randNum];
    app[randNum] = app[l];
    app[l] = pivot;

    while(low < high){
      while(low < high && app[high]->strength > pivot->strength){
        high--;
      }
      if(low < high){
        app[low++] = app[high];
      }
      while(low < high && app[low]->strength < pivot->strength){
        low++;
      }
      if(low < high){
        app[high--] = app[low];
      }
    }
    app[low] = pivot;
    sortByStrength(app,l,low-1);
    sortByStrength(app,low+1,r);
  }
}
void printApple(apple** app,int l,int n)
{
  for(int i=l; i<=n; i++){
    cout << app[i]->high << "\t" << app[i]->strength << endl;
  }
}